/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-03-28
 * Time: 13:57
 */
public class Solution {
    public int maxArea(int[] height) {
        int left = 0,right = height.length - 1,max = 0;
        while(left < right){
            if(height[left] >= height[right]){
                max = Math.max(max,(height[right] * (right - left)));
                right--;
            }else{
                max = Math.max(max,(height[left] * (right - left)));
                left++;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] array = new int[]{1,8,6,2,5,4,8,3,7};
        int ret = solution.maxArea(array);
        System.out.println(ret);
    }
}